<template>
		<el-container>
			<el-main>
				<el-col :span="50">
					<el-form :model="form" :rules="rules" :disabled="mode==='show'" ref="dialogForm" label-width="120px">
								<el-form-item label="公司支持子公司" prop="sysCompanyId">
									<el-input v-model="form.sysCompanyId" placeholder="请输入公司支持子公司" clearable></el-input>
								</el-form-item>
								<el-form-item label="总公司id" prop="parentId">
									<el-input v-model="form.parentId" placeholder="请输入总公司id" clearable></el-input>
								</el-form-item>
								<el-form-item label="公司名" prop="companyName">
									<el-input v-model="form.companyName" placeholder="请输入公司名" clearable></el-input>
								</el-form-item>
								<el-form-item label="国家城市path" prop="regionPath">
									<el-input v-model="form.regionPath" placeholder="请输入国家城市path" clearable></el-input>
								</el-form-item>
								<el-form-item label="地址" prop="address">
									<el-input v-model="form.address" placeholder="请输入地址" clearable></el-input>
								</el-form-item>
								<el-form-item label="电话" prop="phone">
									<el-input v-model="form.phone" placeholder="请输入电话" clearable></el-input>
								</el-form-item>
								<el-form-item label="邮箱" prop="email">
									<el-input v-model="form.email" placeholder="请输入邮箱" clearable></el-input>
								</el-form-item>
								<el-form-item label="传真" prop="fax">
									<el-input v-model="form.fax" placeholder="请输入传真" clearable></el-input>
								</el-form-item>
								<el-form-item label="邮编" prop="zip">
									<el-input v-model="form.zip" placeholder="请输入邮编" clearable></el-input>
								</el-form-item>
								<el-form-item label="logo图片地址 前后台使用" prop="logo">
									<el-input v-model="form.logo" placeholder="请输入logo图片地址 前后台使用" clearable></el-input>
								</el-form-item>
								<el-form-item label="备案 法人身份证正面" prop="baImg1">
									<el-input v-model="form.baImg1" placeholder="请输入备案 法人身份证正面" clearable></el-input>
								</el-form-item>
								<el-form-item label="备案 法人身份证反面" prop="baImg2">
									<el-input v-model="form.baImg2" placeholder="请输入备案 法人身份证反面" clearable></el-input>
								</el-form-item>
								<el-form-item label="备案 营业执照" prop="baImg3">
									<el-input v-model="form.baImg3" placeholder="请输入备案 营业执照" clearable></el-input>
								</el-form-item>
								<el-form-item label="备案 税务证" prop="baImg4">
									<el-input v-model="form.baImg4" placeholder="请输入备案 税务证" clearable></el-input>
								</el-form-item>
								<el-form-item label="对公账户信息" prop="dgyhDesc">
									<el-input v-model="form.dgyhDesc" placeholder="请输入对公账户信息" clearable></el-input>
								</el-form-item>
								<el-form-item label="qq" prop="qq">
									<el-input v-model="form.qq" placeholder="请输入qq" clearable></el-input>
								</el-form-item>
								<el-form-item label="前台网址" prop="frontUrl">
									<el-input v-model="form.frontUrl" placeholder="请输入前台网址" clearable></el-input>
								</el-form-item>
								<el-form-item label="备案信息" prop="rightMsg">
									<el-input v-model="form.rightMsg" placeholder="请输入备案信息" clearable></el-input>
								</el-form-item>
								<el-form-item label="服务热线" prop="hotLine">
									<el-input v-model="form.hotLine" placeholder="请输入服务热线" clearable></el-input>
								</el-form-item>
								<el-form-item label="备注" prop="msg">
									<el-input v-model="form.msg" placeholder="请输入备注" clearable></el-input>
								</el-form-item>
								<el-form-item label="0 1" prop="state">
									<el-input v-model="form.state" placeholder="请输入0 1" clearable></el-input>
								</el-form-item>
								<el-form-item label="缴费日期" prop="jfDate">
									<el-input v-model="form.jfDate" placeholder="请输入缴费日期" clearable></el-input>
								</el-form-item>
								<el-form-item label="最近缴费日期" prop="jfLastTime">
									<el-input v-model="form.jfLastTime" placeholder="请输入最近缴费日期" clearable></el-input>
								</el-form-item>
                            </el-form>
				</el-col>
			</el-main>
			<el-footer>
				<el-button :loading="isSaveing" @click="submit()" type="primary" size="small">保 存</el-button>
			</el-footer>
		</el-container>
</template>
<script>
	import systemAPI from '@/api/system/sysCompany';
	export default {
		emits: ['success', 'closed'],
		data() {
			return {
				mode: "add",
				titleMap: {
					add: '新增',
					edit: '编辑',
					mode: ''
				},
				visible: false,
				isSaveing: false,
				//表单数据
				form: {
					sysCompanyId: "",
					parentId: "",
					companyName: "",
					regionPath: "",
					address: "",
					phone: "",
					email: "",
					fax: "",
					zip: "",
					logo: "",
					baImg1: "",
					baImg2: "",
					baImg3: "",
					baImg4: "",
					dgyhDesc: "",
					qq: "",
					frontUrl: "",
					rightMsg: "",
					hotLine: "",
					msg: "",
					state: "",
					jfDate: "",
					jfLastTime: "",
				},
				//验证规则
				rules: {
					userName: [
						{required: true, message: '请输入名称'}
					],
					userAge: [
						{pattern: /^[0-9]*$/, message: '年龄需为数字', trigger: 'blur'}
					],
					price: [
						{pattern: /^\d+(\.\d+)?$/, message: '价格需为数字', trigger: 'blur'}
					]
				}
			}
		},
		mounted() {
			this.getDataCo();
		},
		methods: {
			//显示
			open(mode='add'){
				this.mode = mode;
				return this;
			},
			//表单提交方法
			submit(){
				this.$refs.dialogForm.validate(async (valid) => {
					if(valid){
						this.isSaveing = true;
						var res = await systemAPI.sysCompany.save.post(this.form);
						this.isSaveing = false;
						if(res.code === 2000){
							this.$emit('success', this.form, this.mode);
							this.visible = false;
							this.$message.success(res.message);
						}else{
							this.$alert(res.message, "提示", {type: 'error'})
						}
					}
				});
			},
			async getDataCo(){
				var res = await systemAPI.sysCompany.getById.getById(-199);
				console.log(res);
				if(res.code === 2000){
				  this.setData(res.data);
				}else{
				  this.$alert(res.message, "提示", {type: 'error'});
				}
			},
			//表单注入数据
			setData(data){
				this.form.sysCompanyId = data.sysCompanyId;
				this.form.parentId = data.parentId;
				this.form.companyName = data.companyName;
				this.form.regionPath = data.regionPath;
				this.form.address = data.address;
				this.form.phone = data.phone;
				this.form.email = data.email;
				this.form.fax = data.fax;
				this.form.zip = data.zip;
				this.form.logo = data.logo;
				this.form.baImg1 = data.baImg1;
				this.form.baImg2 = data.baImg2;
				this.form.baImg3 = data.baImg3;
				this.form.baImg4 = data.baImg4;
				this.form.dgyhDesc = data.dgyhDesc;
				this.form.qq = data.qq;
				this.form.frontUrl = data.frontUrl;
				this.form.rightMsg = data.rightMsg;
				this.form.hotLine = data.hotLine;
				this.form.msg = data.msg;
				this.form.state = data.state;
				this.form.jfDate = data.jfDate;
				this.form.jfLastTime = data.jfLastTime;
			}
		}
	}
</script>
<style>
</style>
